package br.com.medvagas.comum.entidade;

import java.io.Serializable;
import javax.persistence.*;

import java.util.Set;


/**
 * The persistent class for the municipio database table.
 * 
 */
@Entity
@Table(name="municipio")
@NamedQueries({
	@NamedQuery(
		name="Municipio.consultarPorUf", 
		query="select m from Municipio m where m.uf.siglaUf = :siglaUf")
})  
public class Municipio implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="cod_ibge")
	private String codIbge;

	private String capital;

	private String nome;

	//bi-directional many-to-one association to Empresa
	@OneToMany(mappedBy="municipio")
	private Set<Empresa> empresas;

	//bi-directional many-to-one association to Uf
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="sigla_uf")
	private Uf uf;

    public Municipio() {
    }

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((codIbge == null) ? 0 : codIbge.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Municipio other = (Municipio) obj;
		if (codIbge == null) {
			if (other.codIbge != null)
				return false;
		} else if (!codIbge.equals(other.codIbge))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Municipio [codIbge=" + codIbge + ", nome=" + nome + "]";
	}

	public String getCodIbge() {
		return this.codIbge;
	}

	public void setCodIbge(String codIbge) {
		this.codIbge = codIbge;
	}

	public String getCapital() {
		return this.capital;
	}

	public void setCapital(String capital) {
		this.capital = capital;
	}

	public String getNome() {
		return this.nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public Set<Empresa> getEmpresas() {
		return this.empresas;
	}

	public void setEmpresas(Set<Empresa> empresas) {
		this.empresas = empresas;
	}
	
	public Uf getUf() {
		return this.uf;
	}

	public void setUf(Uf uf) {
		this.uf = uf;
	}
	
}